{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ac12e0ef",
   "metadata": {},
   "source": [
    "- references\n",
    "    - https://www.nvidia.com/en-us/ai-on-rtx/chat-with-rtx-generative-ai/\n",
    "    - https://github.com/NVIDIA/trt-llm-rag-windows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "195f1592",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-15T02:29:34.494933Z",
     "start_time": "2024-02-15T02:29:34.485675Z"
    }
   },
   "outputs": [],
   "source": [
    "from IPython.display import Image"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "361bd9e3",
   "metadata": {},
   "source": [
    "## 介绍下我的系统环境"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "317a61b9",
   "metadata": {},
   "source": [
    "- 双系统\n",
    "    - 一个 2T 的固态硬盘\n",
    "    \n",
    "    ```\n",
    "    sudo apt install smartmontools -y\n",
    "    sudo smartctl -a /dev/nvme0n1 | grep -i model\n",
    "    ```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5b951bb1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-14T13:46:42.143816Z",
     "start_time": "2024-02-14T13:46:42.133527Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"../imgs/990_pro.png\" width=\"500\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Image(url='../imgs/990_pro.png', width=500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1437e2d6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-14T13:48:38.295898Z",
     "start_time": "2024-02-14T13:48:38.286073Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"../imgs/nvme_partition.png\" width=\"500\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# /media/whaow: windows 系统位置\n",
    "# sudo mount /dev/nvme0n1p3 /media/whaow\n",
    "Image(url='../imgs/nvme_partition.png', width=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c636004b",
   "metadata": {},
   "source": [
    "## 关于 nvidia-chat-with-rtx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8f0d64b3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-02-15T02:29:44.040187Z",
     "start_time": "2024-02-15T02:29:44.035092Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"../imgs/nv-chat-rtx-version.png\" width=\"400\"/>"
      ],
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Image(url='../imgs/nv-chat-rtx-version.png', width=400)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3951c465",
   "metadata": {},
   "source": [
    "- 最大的特色是傻瓜式安装，以及本地化服务，离线可用；\n",
    "    - 硬件需求较高（主要是需要一张较高配置的显卡，以及未来更大更快的存储空间用于存放格式各样的大模型）\n",
    "        - 此外还有网络问题，嗨。\n",
    "    - 类似 sd-webui；消费级显卡未来的需求可想而知；\n",
    "    - 对于 nvidia，深度绑定软硬件服务；\n",
    "- 目前支持的模型是 Mistral 以及 Llama 4bit 量化，侧面也说明了目前较受认可的开源LLMs；\n",
    "    - Llama 13B INT4 Engine\n",
    "    - Mistral 7B INT4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07bedee7",
   "metadata": {},
   "source": [
    "### 启动或者安装问题"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbdebd23",
   "metadata": {},
   "source": [
    "- 安装时不建议修改默认的安装目录"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e21c1905",
   "metadata": {},
   "source": [
    "`ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True.`"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58a85e5b",
   "metadata": {},
   "source": [
    "- 设置环境变量\n",
    "    - `http_proxy`: `http://127.0.0.1:7890`\n",
    "    - `https_proxy`: `http://127.0.0.1:7890`\n",
    "- 修改 app.py（`C:\\Users\\username\\AppData\\Local\\NVIDIA\\ChatWithRTX\\RAG\\trt-llm-rag-windows-main\\app.py`）\n",
    "    - 添加一行 `os.environ['no_proxy'] = \"localhost,127.0.0.1,::1\"`"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
